package C50;

/**
 * ClassName: C05
 * Package: C50
 * Description:
 *
 * @Author BCXJ
 * @Create 2025/2/28 11:30
 * @Version 1.0
 * @Since 1.0
 */
public class C05 {
    public static void main(String[] args) {
        int[] arr = {1,8,6,2,5,4,8,3,7};
        System.out.println(maxArea(arr));
    }


    public static int maxArea(int[] height) {
        int n = height.length;
        int l = 0, r = n - 1, ans = 0;
        while (l < r) {
            ans = Math.max(ans, Math.min(height[l], height[r]) * (r - l));
            if(height[l] < height[r]) {
                l ++;
            } else {
                r --;
            }
        }
        return ans;
    }
}
